package com.ljx.itbbs.server.user.service.adapter;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil;
import com.ljx.itbbs.common.domain.entity.UserEntity;
import com.ljx.itbbs.common.domain.enums.CommonStatusEnum;
import com.ljx.itbbs.server.user.domain.enums.ActiveEnum;
import com.ljx.itbbs.server.user.domain.vo.resp.UserResp;

import java.util.List;

public class UserAdapter {
    public static UserEntity buildRegisterUser(String username, String password) {
        UserEntity user = new UserEntity();
        user.setUsername(username);
        user.setPassword(password);
        user.setNickname("用户" + RandomUtil.randomNumbers(6));
        user.setAvatar("https://www.minebox.store/uc_server/avatar.php?uid=660&size=small");
        user.setStatus(CommonStatusEnum.NORMAL.getStatus());
        user.setActiveStatus(ActiveEnum.ADMIN.getStatus());
        user.setGrade(1);
        user.setIntegral(0);
        user.setExp(0L);
        return user;
    }

    public static UserResp buildAuthUserResp(UserEntity user, List<String> roleList) {
        UserResp userResp = BeanUtil.copyProperties(user, UserResp.class);
        userResp.setRoleList(roleList);

        return userResp;
    }
}
